<template>
    <view class="animation-container" :class="{ 'animation-end': isAnimationEnd }">
      <view class="book-list" :class="{ 'start-animation': startAnimation }">
        <view 
          v-for="index in 5" 
          :key="index" 
          class="book-page"
          :class="'page' + index"
        ></view>
      </view>
    </view>
  </template>
  
  <script setup>
  import { ref, onMounted } from 'vue'
  
  const startAnimation = ref(false)
  const isAnimationEnd = ref(false)
  
  const emit = defineEmits(['animationEnd'])
  
  onMounted(() => {
    setTimeout(() => {
      startAnimation.value = true
    }, 100)
  
    setTimeout(() => {
      isAnimationEnd.value = true
      emit('animationEnd')
    }, 4000)
  })
  </script>
  
  <style lang="scss" scoped>
  .animation-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: #000;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s;
    
    &.animation-end {
      opacity: 0;
      pointer-events: none;
    }
  }
  
  .book-list {
    width: 300rpx;  // 调整宽度
    height: 450rpx; // 调整高度
    position: relative;
    transform-style: preserve-3d;
    perspective: 1000px;
    transition: transform 2.5s ease;
    
    &.start-animation {
      transform: rotateX(35deg);
      
      .book-page {
        &.page1 {
          transform: rotateY(-180deg);
          transition: transform 2s ease 0.3s;
        }
        &.page2 {
          transform: rotateY(-180deg);
          transition: transform 2s ease 0.6s;
        }
        &.page3 {
          transform: rotateY(-180deg);
          transition: transform 2s ease 0.9s;
        }
        &.page4 {
          transform: rotateY(-180deg);
          transition: transform 2s ease 1.2s;
        }
        &.page5 {
          transform: rotateY(-180deg);
          transition: transform 2s ease 1.5s;
        }
      }
    }
  }
  
  .book-page {
    position: absolute;
    width: 100%;
    height: 100%;
    transform-origin: left;
    background: rgba(255, 255, 255, 0.1);
    
    &.page1 { background-color: rgba(255, 255, 255, 0.12); }
    &.page2 { background-color: rgba(255, 255, 255, 0.10); }
    &.page3 { background-color: rgba(255, 255, 255, 0.08); }
    &.page4 { background-color: rgba(255, 255, 255, 0.06); }
    &.page5 { background-color: rgba(255, 255, 255, 0.04); }
  }
  </style>